var HM=HM|| {};
function swiperAnimateCache(){
	$(".ani").each(function(index, element) {
         $(this).attr("swiper-animate-style-cache","").css({"visibility": "hidden"})
    });
}
function swiperAnimate(a,num){
	clearSwiperAnimate();
	num==undefined?num=0:num;
	$(a).eq(num).each(function(index, element) {
        var o=$(this);
		var b = o.find(".ani");
		b.each(function(index, element) {
              effect = $(this).attr("swiper-animate-effect");
			  duration = $(this).attr("swiper-animate-duration");
			  delay = $(this).attr("swiper-animate-delay");
              $(this).css({"visibility": "hidden","animation-duration":duration,"-webkit-animation-duration":duration,"animation-delay":delay,"-webkit-animation-delay":delay,"visibility":"visible"});
			  $(this).addClass(effect+ " animated")
        });
    });
}
function clearSwiperAnimate() {
	 $(".ani").each(function(index, element) {
        effect =$(this).attr("swiper-animate-effect");
		$(this).removeAttr("style").attr("swiper-animate-style-cache","").css({"visibility": "hidden"}).removeClass(effect).removeClass("animated")
    });	
}
HM= {
	 getHeight:function(){
	 	 $(".hm-head").css({"height":$(window).height()});
	 	 $(".hm-zhibo").css({"margin-top":$(window).height()});
     function video_width(){
         var height = window.innerHeight,
           width = document.body.clientWidth;
      var leftOffset =-(height*1280/720 - width)/2;
      var ratio = height/width;
       if(ratio>(720/1280)){
          if(leftOffset<0){
           $("#video-bg").css({"width":"auto", "height":"100%","margin-left":leftOffset+"px"});
          }
       }
       else
       {
         $("#video-bg").css({ "width":"100%",height:"auto","margin-left":0});
       }
     }
     video_width()
     $(window).resize(function() {
        video_width()
      });
	 	 $(window).bind('scroll', function() {
	 	 	if($(document).scrollTop()>=$(window).height()){
               $(".hm-head").css({"top":"auto"});;
	 	 	}
	 	 	else
	 	 	{
              $(".hm-head").css({"top":0});
	 	 	}
	 	 	if($(document).scrollTop()>=$(".hm-jigou").offset().top+600){
               swiperAnimate(".nn-box",0);
	 	 	}
	 	 })
	 },
	 pl_scroll:function(){
        $(".pl-list .scroll").each(function(index, el) {
        	var T=$(this);
            var li=T.find("li");
            var timer=null;
            clearInterval(timer);
            timer=setInterval(function(){
            	var first=T.find("li:first");
                 first.fadeOut('700', function() {
                	 $(this).remove();
                	 T.find("ul").animate({top:-55},function(){
                	 	$(this).css({top:0})
                	 });
                	 first.show().appendTo(T.find("ul"))
                });
            },3000)
        });
	 }
}
$(function(){
   //自动获取首页高度
   HM.getHeight();
   //评论滚动
   HM.pl_scroll();
  
})
